{% extends 'cms/base.html' %}

{% block title %}评论管理{% endblock %}

{% block head %}
<script src="{{ url_for('static',filename='cms/js/comments.js') }}"></script>
{% endblock %}

{% block page_title %}
    {{ self.title() }}
{% endblock %}

{% block main_content %}
    <table class="table table-bordered">
    <thead>
    <tr>
      <th>内容</th>
      <th>发布时间</th>
      <th>所属帖子</th>
      <th>作者</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {% for comment in comments %}
      <tr>
        <td>{{ comment.content }}</td>
        <td>{{ comment.create_time }}</td>
        <td><a href="{{ url_for('front.post_detail',post_id=comment.post.id) }}">{{ comment.post.title }}</a></td>
        <td>{{ comment.author.username }}</td>
        <td>
          {% if comment.is_active %}
            <button class="btn btn-danger btn-sm active-btn" data-active="1" data-comment-id="{{ comment.id }}">隐藏</button>
          {% else %}
            <button class="btn btn-info btn-sm active-btn" data-active="0" data-comment-id="{{ comment.id }}">取消隐藏</button>
          {% endif %}
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
{% endblock %}